package cn.com.tbshuda.mysql.mysql.config;

import cn.com.tbshuda.mysql.mysql.Bean.Result;
import cn.com.tbshuda.mysql.mysql.Bean.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @author He Changjie on 2020/9/5
 */
@Slf4j
@ControllerAdvice
public class ValidatedExceptionHandler {

//    /**
//     * 处理@Validated参数校验失败异常
//     * @param exception 异常类
//     * @return 响应
//     */
//    @ResponseBody
//    @ResponseStatus(HttpStatus.BAD_REQUEST)
//    @ExceptionHandler(MethodArgumentNotException.class)
//    public Result exceptionHandler(MethodArgumentNotException exception){
//        String result = exception.getExceptionMsg();
//        return ResultUtil.validatedException(result);
//    }
}
